import { defineStore } from "pinia";
import { ref } from "vue";
import { queryWebCount, queryWebInfo } from "@/api/webInfo.api";
import { WebCount, WebInfo } from "@/types/webInfo";
export const useWebInfoStore = defineStore("webInfoStore", () => {
  // 网站基本信息
  const webInfo = ref<WebInfo>(new WebInfo());
  const getWebInfo = async () => {
    const res = await queryWebInfo();
    if (res.code === 200) {
      webInfo.value = res.data || new WebInfo();
    }
  };
  //  三个统计信息
  const webCount = ref<WebCount>(new WebCount());
  const getWebCount = async () => {
    const res = await queryWebCount();
    if (res.code === 200) {
      webCount.value = res.data || new WebCount();
    }
  };
  return {
    webInfo,
    getWebInfo,
    webCount,
    getWebCount,
  };
});
